home *** CD-ROM | disk | FTP | other *** search
- function mKill()
- {
- this._parent.mKillObject(this);
- }
- function mPhysics(interval)
- {
- var newPosX = this.intPosX + this.intVelX * interval;
- var newPosY = this.intPosY + this.intVelY * interval;
- this.intPosX = newPosX;
- this.intPosY = newPosY;
- }
- function mReset()
- {
- this.oWave = this._parent.oWave;
- this.intPosX = 0;
- this.intPosY = -10;
- this.intVelX = 0;
- this.intVelY = 0;
- this.intGravity = -1;
- this.strmedia = "wave";
- this.intAngle = 0;
- this.strMode = "paddling";
- this.intMaxVel = 30;
- this.hexColorRopa = this._parent.hexColorRopa;
- this.hexColorTabla = this._parent.hexColorTabla;
- }
- function mStepFrame(interval)
- {
- this.mGetMedia();
- this.mTestCollisions();
- if(this.strmedia == "air")
- {
- this.intVelY += this.intGravity * interval;
- }
- if(this.strmedia == "wave")
- {
- var absVel = Math.sqrt(this.intVelX * this.intVelX + this.intVelY * this.intVelY);
- if(Math.sin(this.intAngle) < 0)
- {
- absVel *= 1 - Math.sin(this.intAngle) / 50;
- }
- else
- {
- absVel *= 0.999;
- }
- this.intVelX = absVel * Math.cos(this.intAngle);
- this.intVelY = absVel * Math.sin(this.intAngle);
- }
- this.SpeedLimit();
- this.mPhysics(interval);
- }
- function SpeedLimit()
- {
- if(this.intVelX > this.intMaxVel)
- {
- this.intVelX = this.intMaxVel;
- }
- if(this.intVelX < - this.intMaxVel)
- {
- this.intVelX = - this.intMaxVel;
- }
- }
- function mGetMedia()
- {
- if(this.intPosY > 0)
- {
- if(this.strmedia == "wave")
- {
- this.intAccAngle = 0;
- }
- this.strmedia = "air";
- }
- else if(this.intPosY > this.oWave.mGetGround())
- {
- if(this.strmedia == "air")
- {
- if(Math.sin(this.intAngle) >= 0)
- {
- this.strmedia = "missed";
- }
- else
- {
- var vueltas = Math.floor(Math.abs(this.intAccAngle / 3.141592653589793));
- if(vueltas > 0)
- {
- var score = 100 * (vueltas * vueltas);
- this._parent.mNewScore(score,this.intPosX,0,506);
- }
- this.strmedia = "wave";
- }
- }
- else
- {
- this.strmedia = "wave";
- }
- }
- else
- {
- this.strmedia = "ground";
- }
- }
- function mTestCollisions()
- {
- if(this.intPosX < this.oWave.intPosX)
- {
- this.mCollide("wave");
- }
- if(this.strmedia == "ground")
- {
- this.mCollide("ground");
- }
- if(this.strmedia == "missed")
- {
- this.mCollide("missed");
- }
- if(this.intPosX > this.oWave.intFinish)
- {
- this._parent.mJumpLevel();
- }
- }
- function mLooseLife()
- {
- this.oImage.mSetPose("fall");
- this.sndVida.start();
- this._parent.mLooseLife();
- }
- function mCollide(strID)
- {
- if(strID == "wave")
- {
- this.sndOla.start();
- this.mLooseLife();
- }
- if(strID == "ground")
- {
- this.mLooseLife();
- }
- if(strID == "missed")
- {
- this.mLooseLife();
- }
- if(strID == "obst")
- {
- this.oImage.mSetPose("hit");
- this.sndObstaculo.start();
- if(this.intVelX > 0)
- {
- this.intVelX = 10;
- }
- else
- {
- this.intVelX = -10;
- }
- }
- if(strID == "bomb")
- {
- this.mLooseLife();
- }
- if(strID == "life")
- {
- this._parent._parent.mAddLife();
- this._parent.vidasdisplay.mRefresh();
- }
- }
- function mRotate(aint)
- {
- this.intAngle += aint;
- this.intAccAngle += aint;
- if(this.intAngle > 6.283185307179586)
- {
- while(this.intAngle > 6.283185307179586)
- {
- this.intAngle -= 6.283185307179586;
- }
- }
- if(this.intAngle < -6.283185307179586)
- {
- while(this.intAngle < -6.283185307179586)
- {
- this.intAngle += 6.283185307179586;
- }
- }
- }
- function mGetPoints()
- {
- var intLargo = 65;
- var pto = new Object();
- pto.x = this.intPosX;
- pto.y = this.intPosY;
- var arrPnts = new Array();
- ppto.x = 0.1 * intLargo * Math.cos(this.intAngle) + pto.x;
- ppto.y = 0.1 * intLargo * Math.sin(this.intAngle) + pto.y;
- arrPnts.push(ppto);
- ppto = new Object();
- ppto.x = 0.8 * intLargo * Math.cos(this.intAngle) + pto.x;
- ppto.y = 0.8 * intLargo * Math.sin(this.intAngle) + pto.y;
- arrPnts.push(ppto);
- ppto = new Object();
- ppto.x = 0.5 * intLargo * Math.cos(this.intAngle) + pto.x;
- ppto.y = 0.5 * intLargo * Math.sin(this.intAngle) + pto.y;
- arrPnts.push(ppto);
- return arrPnts;
- }
- this.sndObstaculo = new Sound(this);
- this.sndObstaculo.attachSound("obstaculo1.wav");
- this.sndOla = new Sound(this);
- this.sndOla.attachSound("ola.wav");
- this.sndVida = new Sound(this);
- this.sndVida.attachSound("vida.wav");
- this.mReset();
-